//package com.yf.tz.service.impl;
//
//import com.yf.tz.dao.MallOrderDao;
//import com.yf.tz.dao.SaleOrderDao;
//import com.yf.tz.entity.MallOrderEntity;
//import com.yf.tz.entity.SaleOrderEntity;
//import com.yf.tz.enums.MallOrderOrderStatusEnum;
//import com.yf.tz.enums.MallOrderPaidEnum;
//import com.yf.tz.service.CronService;
//import com.yf.tz.service.MallOrderService;
//import com.yf.tz.service.SaleOrderService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Service;
//
//import java.util.Date;
//import java.util.List;
//
//@Slf4j
//@Service
//public class CronServiceImpl implements CronService {
//
//    @Autowired
//    private MallOrderDao mallOrderDao;
//
//    @Autowired
//    private MallOrderService mallOrderService;
//
//    @Autowired
//    private SaleOrderDao saleOrderDao;
//
//    @Autowired
//    private SaleOrderService saleOrderService;
//
//
//    @Override
//    @Scheduled(fixedDelay =  5 * 60 * 1000)
//    public void cancelOrder() {
//        Date date = new Date();
//        date = new Date(date.getTime() - 30 * 60 * 1000);
//        List<MallOrderEntity> orderEntityList = mallOrderDao.findBeforeTimeAndPaidAndStatus(date, MallOrderPaidEnum.NO.getIndex(), MallOrderOrderStatusEnum.NEW.getIndex());
//        orderEntityList.forEach(orderEntity -> {
//            try {
//                mallOrderService.cancelOrder(null, orderEntity.getId());
//            } catch (Exception e) {
//                log.error("取消商城订单出错ID:" + orderEntity.getId() + "=" + e.getMessage());
//            }
//        });
//        List<SaleOrderEntity> saleOrderEntities = saleOrderDao.findBeforeTimeAndPaidAndStatus(date, MallOrderPaidEnum.NO.getIndex(), MallOrderOrderStatusEnum.NEW.getIndex());
//        saleOrderEntities.forEach(orderEntity -> {
//            try {
//                saleOrderService.cancelOrder(null, orderEntity.getId());
//            } catch (Exception e) {
//                log.error("取消堂食订单出错ID:" + orderEntity.getId() + "=" + e.getMessage());
//            }
//        });
//
//    }
//}
